home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Collections: Scope
/
Scope Disk #010 (199x)(Scope PD)(US)[WB].zip
/
Scope Disk #010 (199x)(Scope PD)(US)[WB].adf
/
BlitLab3
/
mem.c
< prev
next >
Wrap
C/C++ Source or Header
|
1988-05-14
|
758b
|
40 lines
/*
* Memory allocation and deallocation for BlitLab.
*/
#include "structures.h"
struct memnode {
struct memnode * next ;
long size ;
} ;
static struct memnode *head ;
/*
* Replacement for AllocMem. If not enough memory, we exit.
*/
void *allocmem(size, type)
long size ;
long type ;
{
struct memnode *p ;
extern void *AllocMem() ;
p = (struct memnode *)AllocMem(size + sizeof(struct memnode), type) ;
if (p==NULL)
error("! out of memory") ;
p->size = size + sizeof(struct memnode) ;
p->next = head ;
head = p ;
return(p + 1) ;
}
/*
* Frees all allocated memory.
*/
freemem() {
struct memnode *p ;
while (head != NULL) {
p = head->next ;
FreeMem(head, head->size) ;
head = p ;
}
}